<%--
  Created by IntelliJ IDEA.
  User: dqf
  Date: 2014/12/9
  Time: 17:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<div class="row" style="padding:2px">
  <div class="col-sm-12 col-md-12 col-lg-12">
    <div class="form-group">
      <a id="ajax_bidstart_btn_add" class="btn btn-default " data-toggle="modal"><i class="fa fa-lg fa-plus"></i>新建招标立项表</a>
      <a id="ajax_bidprocess_btn_add" class="btn btn-default " data-toggle="modal"><i class="fa fa-lg fa-plus"></i>新建招标过程表</a>
      <a id="ajax_bidresult_btn_add" class="btn btn-default " data-toggle="modal"><i class="fa fa-lg fa-plus"></i>新建招标结果表</a>
      <a id="ajax_bidresult_btn_all" class="btn btn-default pull-right "><i class="fa fa-lg fa-refresh"></i>显示所有项目</a>
    </div>
  </div>
</div>
<!-- rows -->
<!-- widget grid -->
<section id="widget-grid" class="">
  <input id="keyId" name="keyId" hidden value="<s:property value="keyId"></s:property> "/>
  <!-- row -->
  <div class="row">
    <!-- NEW WIDGET START -->
    <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
      <!-- Widget ID (each widget will need unique ID)-->
      <div class="jarviswidget " id="wid-id-0" data-widget-editbutton="false"
           data-widget-colorbutton="false"
           data-widget-togglebutton="false"
           data-widget-deletebutton="false"
           data-widget-fullscreenbutton="true"
           data-widget-custombutton="false"
           data-widget-sortable="false">

        <header>
          <span class="widget-icon"> <i class="fa fa-table"></i> </span>
          <h2>招标立项表</h2>
        </header>
        <!-- widget div-->
        <div>
          <!-- widget edit box -->
          <div class="jarviswidget-editbox">
            <!-- This area used as dropdown edit box -->

          </div>
          <!-- end widget edit box -->

          <!-- widget content -->
          <div class="widget-body no-padding">
            <div class="col-sm-12 col-md-12 col-lg-12">
              <div class=" ">
                <div class="row" id="ajax_bidstart_list_row">
                  <table id="ajax_bidstart_table" class="table table-striped table-bordered table-hover">
                  </table>
                  <div id="ajax_bidstart_list_page">
                  </div>
                </div>

              </div>
            </div>

          </div>
          <!-- end widget content -->
        </div>
        <!-- end widget div -->
      </div>
      <!-- end widget -->
    </article>
    <!-- WIDGET END -->

  </div>

  <!-- end row -->

  <!-- end row -->

</section>
<!-- end widget grid -->



<script type="text/javascript">
  // DO NOT REMOVE : GLOBAL FUNCTIONS!
  pageSetUp();

  function reload(){
    loadURL("ajax!bidstart.action",$('#content'));
  }

</script>

<script type="text/javascript">
  $(function(){
    load_bidstart_jqGrid();
  });
  function load_bidstart_jqGrid(){
    jQuery("#ajax_bidstart_table").jqGrid({
      url:'ajax-bidstart!list.action?keyId='+$("input#keyId").val(),
      datatype: "json",
      colNames:['项目名称 ',"招标类型",'拟招标限额（拦标价）万元',"归档日期","文档状态","操作","id"],
      colModel:[
        {name:'name',index:'name', width:120,sortable:false},
        {name:'type',index:'type', width:80,sortable:true},
        {name:'money',index:'money', width:80,sortable:true},
        {name:'overDate',index:'overDate', width:80,sortable:false},
        {name:'processState',index:'processState', width:120,sortable:false},
        {name:'act',index:'act', width:150,sortable:false,fixed:true},
        {name:'id',index:'id', width:50,hidden:true},
      ],
      rowNum : 10,
      rowList:[10,20,30],
      pager : '#ajax_bidstart_list_page',
      sortname : 'endDate',
      sortorder : "desc",
      gridComplete:function(){
        var ids=$("#ajax_bidstart_table").jqGrid('getDataIDs');
        for(var i=0;i<ids.length;i++){
          var cl=ids[i];
          de="<button class='btn btn-default' data-original-title='查看' onclick=\"fn_bidstart_read('"+cl+"');\"><i class='fa fa-eye'></i>查看</button>"+" ";
          jQuery("#ajax_bidstart_table").jqGrid('setRowData',ids[i],{act:de});
        }
        $(".ui-jqgrid-bdiv").css("overflow-x","hidden");
        jqGridStyle();
      },
      jsonReader: {
        root: "dataRows",
        page: "page",
        total: "total",
        records: "records",
        repeatitems : false
      },
      multiselect : true,
      rownumbers:true,
      gridview:true,
      shrinkToFit:true,
      viewrecords: true,
      autowidth: true,
      height:'auto',
      forceFit:true,
      loadComplete: function() {
      }
    });
    $(window).on('resize.jqGrid', function() {
      jQuery("#ajax_bidstart_table").jqGrid('setGridWidth', $("#ajax_bidstart_list_row").width());
    })

    jQuery("#ajax_bidstart_table").jqGrid('navGrid', "#ajax_bidstart_list_page", {
      edit : false,
      add : false,
      del : false,
      search:false
    });
  };

  $("#ajax_bidstart_btn_add").click(function(){
    loadURL("ajax-bidstart!input.action",$('#content'));
  });

  function fn_bidstart_read(id){
    loadURL("ajax-bidstart!read.action?keyId="+id,$('#content'));
  }
  $("#ajax_bidprocess_btn_add").click(function(){
    var gridObj = $("#ajax_bidstart_table").jqGrid("getGridParam","selrow");
    if(!gridObj){
      var data={state:400,message:"请选择招标信息",title:"操作状态"};
      _show(data);
      return false;
    };

    loadURL("ajax-bidprocess!input.action?bidstartid="+gridObj,$('#content'));
  });
  $("#ajax_bidresult_btn_add").click(function(){
    var gridObj = $("#ajax_bidstart_table").jqGrid("getGridParam","selrow");
    if(!gridObj){
      var data={state:400,message:"请选择招标信息",title:"操作状态"};
      _show(data);
      return false;
    };
    loadURL("ajax-bidresult!input.action?bidstartid="+gridObj,$('#content'));
  })
  $("#ajax_bidresult_btn_all").unbind("click").bind("click",function(){
    $("input#keyId").val("");
    $("#ajax_bidresult_table").jqGrid('setGridParam',{url:'ajax-bidresult!list.action'}).trigger("reloadGrid");
  });
</script>

